package org.leaf.green.b2b

class Distribution {//配送单

    String serialNumber//序号
    Retailer retailer//门店
    Date date//日期
    Staff maker//制单人
    Staff driver//送货人
    Boolean approved//审批状态

    Date dateCreated
    Date lastUpdated

    static hasMany = [details : DistributionDetail]

    static constraints = {
        serialNumber(nullable:false, blank : false, unique : true, maxSize : 11)
        retailer(nullable:false)
        date(nullable:false)
        maker(nullable:false)
        driver(nullable:false)
        approved(nullable:false)
    }

    String toString(){
        return "$serialNumber"
    }

    static mapping = {
        table 'B2B_DISTRIBUTION'
        details cascade:"all-delete-orphan", sort:"serialNumber", batchSize: 100
    }
}
